<template>
	<div style="height:3000px">
		<v-card>

			<v-tabs color="red">
				<v-tab>
					MES系统配置
				</v-tab>
				<v-tab>
					WMS系统配置
				</v-tab>
				<v-tab>
					PDM系统配置
				</v-tab>
				<v-tab>
					SPM系统配置
				</v-tab>

				<!-- MES系统配置-->
				<v-tab-item>
					<mesconfig></mesconfig>
				</v-tab-item>

				<!--WMS系统配置 -->
				<v-tab-item>
					<v-card>
						<v-card-title>
						</v-card-title>
						<v-card-text>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="SyncERPWareCode">
								首次同步ERP仓库
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="InitPurchaseInStorage">
								首次同步采购入库单
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="InitOtherInStorgeOrder">
								首次同步其它入库单
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="InitOtherOutStorageOrder">
								首次同步ERP其它出库单
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="InitWms_base_warehouse">
								初始化仓库信息并同步给ERP
							</v-btn>
						</v-card-text>
					</v-card>
				</v-tab-item>

				<!--PDM系统配置 -->
				<v-tab-item>
					<v-card>
						<v-card-title>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="SyncERPAllUnits">
								同步ERP所有单位
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="syncERPInventoryClassClick">
								同步ERP存货分类
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="syncInvClassInitTree">
								同步ERP编码方案
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="SyncERPAllProject">
								同步ERP项目
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary" @click="syncERPAllInventory">
								同步ERP存货
							</v-btn>
							<v-btn class="ml-2 mt-7" small tile color="primary"
								@click="uploadCurrentAccountBookBasicBOMs">
								上传当前账套所有的基础BOM
							</v-btn>
						</v-card-title>
					</v-card>
				</v-tab-item>
				<!--SPM系统配置 -->
				<v-tab-item>
					<v-card>
						<v-card-title>
							<v-btn class="ml-2" small tile color="primary" @click="syncERPUserTypeClick">
								同步ERP用户类型
							</v-btn>
							<v-btn class="ml-2" small tile color="primary" @click="syncERPDepartmentClick">
								同步ERP部门
							</v-btn>
							<v-btn class="ml-2" small tile color="primary" @click="syncERPUserClick">
								同步ERP所有用户信息
							</v-btn>
							<!-- 	<v-btn class="ml-2" small tile color="primary" @click="reportsTestClick">
								报表测试
							</v-btn> -->
							<v-btn class="ml-2" small tile color="primary" @click="pdmBOMSendTOERPClick">
								同步数字化工厂基础BOM转为存货发送给ERP
							</v-btn>
						</v-card-title>
					</v-card>
				</v-tab-item>
			</v-tabs>
		</v-card>
		<v-dialog v-model="UpLoadBasicBomDialog">
			<v-card>
				<v-card-title>上传基础BOM的Excel文件</v-card-title>
				<v-card-text>
					<uploadfile :UpLoad="UpLoadBasicBom"></uploadfile>
				</v-card-text>
				<v-card-actions>
					<v-btn class="ml-2" small tile color="primary" @click="UpLoadBasicBomDialog=false">
						关闭
					</v-btn>
				</v-card-actions>
			</v-card>

			</uploadfile>
		</v-dialog>
	</div>
</template>

<script>
	import UploadFile from '../mes/components/UploadFile.vue'
	import mes_config from './components/config_set/mes_config.vue'
	export default {
		name: 'spm_config_set',
		components: {
			mesconfig: mes_config,
			uploadfile: UploadFile
		},
		data() {
			return {
				UpLoadBasicBomDialog: false,
				UpLoadBasicBom: {
					isUploadSingleImage: false,
					isUploadMultipleFiles: true,
					fileUrl: `SPM/SPMConfig/UploadCurrentAccountBookBasicBOMS?`,
					type: 50
				},

			}
		},
		methods: {
			//同步ERP用户类型
			async syncERPUserTypeClick() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncUserType`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			//同步ERP所有部门到PDM
			async syncERPDepartmentClick() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncERPDepartments`,
					method: 'get'
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			//同步ERP存货
			async syncERPAllInventory() {
				var response = await this.$httpRequestWithNotTimeOut({
					url: `SPM/SPMConfig/SyncERPAllInventorys`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			//同步ERP所有项目
			async SyncERPAllProject() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncERPAllProject`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async syncInvClassInitTree() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncInvClassInitTree`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			//同步ERP存货分类
			async syncERPInventoryClassClick() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncERPInventoryClass`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async SyncERPAllUnits() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncERPAllUnits`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			//同步ERP用户信息
			async syncERPUserClick() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncERPUsers`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			//上传当前账套所有的基础BOM
			async uploadCurrentAccountBookBasicBOMs() {
				this.UpLoadBasicBomDialog = true
			},
			async reportsTestClick() {
				var response = await this.$httpRequest({
					url: `MES/MESProductionValue/Test`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async pdmBOMSendTOERPClick() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncMESBOMTOERP`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},

			async SyncERPWareCode() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/SyncERPWareCode`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async InitPurchaseInStorage() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/InitPurchaseInStorage`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async InitOtherInStorgeOrder() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/InitOtherInStorgeOrder`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async InitOtherOutStorageOrder() {
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/InitOtherOutStorageOrder`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
			async InitWms_base_warehouse(){
				var response = await this.$httpRequest({
					url: `SPM/SPMConfig/InitWms_base_warehouse`,
					method: 'get',
				})
				if (response.status == 1) {
					this.$message.success(response.info)
				} else {
					this.$message.error(response.info)
				}
			},
		}
	}
</script>
